home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.1 (User) / OpenStep 4.1 (User).iso / usr / netware / bin / independentFilter < prev    next >
Encoding:
Text File  |  1996-09-01  |  11.9 KB  |  430 lines

  1. #!/bin/sh
  2.  
  3. #
  4. #    Copyright Novell Inc. 1991
  5. #    (C) Unpublished Copyright of Novell, Inc. All Rights Reserved.
  6. #
  7. #    No part of this file may be duplicated, revised, translated, localized
  8. #    or modified in any manner or compiled, linked or uploaded or
  9. #    downloaded to or from any computer system without the prior written
  10. #    consent of Novell, Inc.
  11. #
  12. #  NetWare Unix Client 
  13. #    Author:  Gary B. Tomlinson
  14. #    Created: 7/9/91
  15. #
  16. #       SCCS ID: 1.4
  17. #         delta: 1/10/92  15:54:17
  18. #
  19. #    MODULE:
  20. #      The independentFilter -    The NUC Client Network Printer NeXT2_0
  21. #                    lpd spooler independent filter program.
  22. #                    Component of the NUC PCLIENT Services.
  23. #
  24. #    ABSTRACT:
  25. #      The independentFilter shell script contains the NeXT platform centric
  26. #      printjob() generic filter interface program, which services all
  27. #      NetWare printers in behalf of printjob() in the lpd(8) spooler.
  28. #      This shell script establishes a pipe which reads from the spooled
  29. #      print file mapped onto STDIN, pushes the appropriate Printer Type
  30. #      dependent filter program, and connects the pipe to the
  31. #      printjob_nucps(1) NetWare printer driver back end.  The printjob()
  32. #      function linked into the lpd(8), PrintPanel(GUI) programs calls
  33. #      this program to spool print files to NetWare QMS print queues.
  34. #
  35. #    ARCHITECTURAL MODEL
  36. #      The NUC Client Print Systems has been designed to plug into the 
  37. #      exsiting NeXT lpd(8) spooler complex as a dependent print system.  It
  38. #      also has been designed to be extensible for various printer type
  39. #      support.  NetWare supports a wide variety of printers, thus a 
  40. #      mechanism which allows printers types to be defined to the NUC, and
  41. #      the associated filter programs for these printers to be plugged into
  42. #      the NUC is necessary.  This filter is a generic filter which sets up
  43. #      the PIPE from lpd(8) to the NUC printer driver printjob_nucps(1), and
  44. #      then pushes (calls) the appropriate dependent filter program into the
  45. #      PIPE passing all the arguments given it by lpd(8).  Thus any standard
  46. #      BSD filter which reads STDIN and writes STDOUT (they all should) can
  47. #      be plugged into the NUC and work without any modification except for
  48. #      the naming conventions used by the NUC.
  49. #
  50. #      The depdendent filter naming conventions used by the NUC are as 
  51. #      follows.  This Shell Script is symbolically linked to the 
  52. #      /usr/netware/bin/PrinterFilters/{PrinterType}/{.cf,.df,.gf,.if,.nf,
  53. #      .rf, .tf,.vf} hidden generic filters.  The real filter for the 
  54. #      PrinterType is then placed in this directory under than name of cf,
  55. #      df, gf, if, nf, rf, tf, or vf according to the type of filter it is.
  56. #      The real depedent filter program inherits the STDIN and STDOUT 
  57. #      necessary to do its work, and is free to push any additional programs
  58. #      into the PIPE that it needs to do its job.  The generic .?? filter
  59. #      supplied by the NUC will attempt to push the dependent real filter
  60. #      into the PIPE, and if it can't will gracefully abort the print
  61. #      request.
  62. #
  63. #    NOTE:
  64. #      The print system model implemented by Novell on NeXT platforms
  65. #      follows the file system model for dependent file systems.  The NetWare
  66. #      NCP Printer Service Class is represented by the following dependent
  67. #      shell commands:
  68. #        independentFilter    (This Shell Script)
  69. #        PostScriptFilter    (Novell Supplied Dependent Filter)
  70. #        DefaultFilter        (Novell Supplied Dependent Filter)
  71. #        displayq_nucps        (Related Program)
  72. #        printjob_nucps        (This Scripts PIPE Child Program)
  73. #        rmjob_nucps        (Related Program)
  74. #
  75. #
  76.  
  77. #
  78. # BEGIN_MANUAL_ENTRY(independentFilter(1), \
  79. #            ./man/shell/print/client/NeXT/independentFilter)
  80. # NAME
  81. #    independentFilter, .cf, .df, .gf, .if, .nf, .rf, .tf, .vf
  82. #            -    Set up Spoolng PIPE of a NeXT print file to
  83. #                NetWare QMS.  Member of the NUC PCLIENT Suite.
  84. #
  85. # SYNOPSIS
  86. #    ./PrinterFilters/{PrinterType}/.cf -xPxWidth -yPxLength -n userName
  87. #            -h hostName [-R resolution] [-M] -p printerName
  88. #            accountingFileName
  89. #
  90. #    ./PrinterFilters/{PrinterType}/.df -xPxWidth -yPxLength -n userName
  91. #            -h hostName [-R resolution] [-M] -p printerName
  92. #            accountingFileName
  93. #
  94. #    ./PrinterFilters/{PrinterType}/.gf -xPxWidth -yPxLength -n userName
  95. #            -h hostName [-R resolution] [-M] -p printerName
  96. #            accountingFileName
  97. #
  98. #    ./PrinterFilters/{PrinterType}/.if [-c] -wChWidth -lChLength -iChIndent
  99. #            [-f printFileName] -n userName -h hostName
  100. #            [-R resolution] [-M] -p printerName accountingFileName
  101. #
  102. #    ./PrinterFilters/{PrinterType}/.nf -xPxWidth -yPxLength -n userName
  103. #            -h hostName [-R resolution] [-M] -p printerName
  104. #            accountingFileName
  105. #
  106. #    ./PrinterFilters/{PrinterType}/.rf -wChWidth -lChLength -n userName
  107. #            -h hostName [-R resolution] [-M] -p printerName
  108. #            accountingFileName
  109. #
  110. #    ./PrinterFilters/{PrinterType}/.tf -xPxwidth -yPxLength -n userName
  111. #            -h hostName [-R resolution] [-M] -p printerName
  112. #            accountingFileName
  113. #
  114. #    ./PrinterFilters/{PrinterType}/.vf -xPxwidth -yPxLength -n userName
  115. #            -h hostName [-R resolution] [-M] -p printerName
  116. #            accountingFileName
  117. #
  118. # OPTIONS
  119. #    accountingFileName    - Name of accounting file.
  120. #    -c            - Pass control characers through.  Those in
  121. #                  addition to CR, LF, FF, and HT. Used with
  122. #                  ASCII files.
  123. #    -f printFileName    - Name of NeXT file being printed.
  124. #    -h hostName        - Name of host print file originated on.
  125. #    -iChIndent        - Left margin indentation in characters. Used
  126. #                  with ASCII files.
  127. #    -lChLength        - Length of page in lines. Used with
  128. #                  ASCII files.
  129. #    -n userName        - Name of User who spooled the file.
  130. #    -p printerName        - Name of printer known by on NeXT work station.
  131. #    -wChWidth        - Width of page in characters. Used with
  132. #                  ASCII files.
  133. #    -xPxWidth        - Width of page in pixels. Used for Bit Maps.
  134. #    -yPxLength        - Length of page in pixels. Used for Bit Maps.
  135. #    -M            - Printer is to be manually fed.
  136. #    -R resolution        - Resolution in Dots Per Inch of print
  137. #                  print resolution desired.
  138. #
  139. # INPUT
  140. #    None.
  141. #
  142. # OUTPUT
  143. #    Successfull    - Silently exits back to printjob() in parent lpd(8)
  144. #    Failure        - Abort message formatted and displayed on
  145. #              STDOUT.
  146. #
  147. # DESCRIPTION
  148. #    The independentFilter sets up the unspooling PIPE of a file being
  149. #    scheduled for lpd[printjob.o] to a remote NetWare printer.  It is
  150. #    invoked by its filter name in printcap(5)/netinfo(5).  This shell
  151. #    script sets up the PIPE to its printjob_nucps(1) NetWare printer
  152. #    driver with the appropriate depedent real filter for the PrinterType
  153. #    pushed.  All filtering is done on the NeXT work station prior to
  154. #    spooling it over over the wire.
  155. #
  156. #    Note:
  157. #        All names are symbolically linked to the same shell script for 
  158. #        servicing.  The called name indicates the filter setup
  159. #        model to be used.
  160. #
  161. # FILES
  162. #       /usr/netware/bin/PrinterFilters/{PrinterType}/.cf
  163. #       /usr/netware/bin/PrinterFilters/{PrinterType}/.df
  164. #       /usr/netware/bin/PrinterFilters/{PrinterType}/.gf
  165. #       /usr/netware/bin/PrinterFilters/{PrinterType}/.if
  166. #       /usr/netware/bin/PrinterFilters/{PrinterType}/.nf
  167. #       /usr/netware/bin/PrinterFilters/{PrinterType}/.rf
  168. #       /usr/netware/bin/PrinterFilters/{PrinterType}/.tf
  169. #       /usr/netware/bin/PrinterFilters/{PrinterType}/.vf
  170. #
  171. # SEE ALSO
  172. #    NWcpsIntroduction(3), printjob_nucps(1)
  173. #
  174. # END_MANUAL_ENTRY
  175. #
  176.  
  177. #
  178. # Default the Variables
  179. #
  180. fileName=""
  181. fileArgs=""
  182. printerName=""
  183. userName=""
  184. ChLength=""
  185. ChWidth=""
  186. BANNER=""
  187. # Parse the Name of the Filter
  188. ifProgramName=`basename $0`
  189.  
  190. # Parse the Path of the Filter
  191. filterPathName=`echo $0 | sed -e 's/\/[^/]*$//'`
  192.  
  193. # Parse the Printer Type
  194. printerType=`basename $filterPathName`
  195.  
  196. PRINTJOB_NUCPS="/usr/netware/bin/printjob_nucps"
  197. DEFAULT_FILTER="/bin/cat"
  198. PS_COMMENT_FILTER=/NextLibrary/Services/PrintFilters.service/psprepare
  199.  
  200. #
  201. # Now read in the .options file for printer customization.
  202. #
  203. # Note:
  204. #    Banners are not processed on NeXT for now.  NetWare configures them
  205. #    on a per printer basis, thus NetWare administrators can print
  206. #    them if they wish.
  207. #        BANNER=-B if NetWare banners are to be printed.
  208. #
  209. #.options
  210.  
  211. #
  212. # Parse the command line to shell script
  213. #
  214. argV=$@
  215. while [ $# != 0 ]
  216. do
  217.     case "$1" in
  218.     
  219.     -c)    # Pass Control Characters, Ignored!!
  220.         ;;
  221.  
  222.     -f)    # Name of print file
  223.         fileArgs="$1 $2";
  224.         fileName="$2";
  225.         shift;
  226.         ;;
  227.  
  228.     -h)    # Host name of user who spooled, Ignored!!
  229.         shift;
  230.         ;;
  231.  
  232.     -i*)    # Left margin indentation, Ignored!!
  233.         ;;
  234.  
  235.     -l*)    # Page Length in Character Lines
  236.         ChLength=$1
  237.         ;;
  238.  
  239.     -n)    # User Name
  240.         userName=$2;
  241.         shift;
  242.         ;;
  243.  
  244.     -p)    # Local Printer Name
  245.         printerName=$2;
  246.         shift;
  247.         ;;
  248.  
  249.     -w*)    # Page Width in Characters
  250.         ChWidth=$1;
  251.         ;;
  252.  
  253.     -x*)    # Page Width in Pixels, Ignored!!
  254.         ;;
  255.  
  256.     -y*)    # Page Length in Pixels, Ignored!!
  257.         ;;
  258.  
  259.     -M)    # Manual feed specified, Ignored!!
  260.         ;;
  261.  
  262.     -R)    # Printer Resolutin in DPI, Ignored!!
  263.         shift;
  264.         ;;
  265.  
  266.     *)    # Accounting File, Ignored!!
  267.         shift;
  268.         ;;
  269.     
  270.     esac
  271.  
  272.         if [ $# != 0  ]
  273.         then
  274.                 shift;
  275.         fi
  276.  
  277. done
  278.  
  279. if [ -z "$printerName" ]
  280. then
  281.     # On NeXT, aquire the Printer Name via the current directory, spool
  282.     # directory names are the same as the printer name
  283.     #
  284.     spoolDirectory=`pwd`
  285.     printerName=`basename $spoolDirectory`
  286. fi
  287.  
  288. #
  289. # Decode the ifProgramName and set up the proper pipe
  290. #
  291. case $ifProgramName in
  292.  
  293. .cf)
  294.     #
  295.     # They need a CIFPLOT filter
  296.     #
  297.     dependentFilter=$filterPathName/cf
  298.     if [ ! -x $dependentFilter ]
  299.     then
  300.         echo "NUC: CIFPLOT filter for Printer Type $printerType not \c"                >/dev/console
  301.         echo "installed, print request aborted!!"                        >/dev/console
  302.         exit 2;
  303.     fi
  304.     ;;
  305.  
  306. .df)
  307.     #
  308.     # They need a DVI TeX filter
  309.     #
  310.     dependentFilter=$filterPathName/df
  311.     if [ ! -x $dependentFilter ]
  312.     then
  313.         echo "NUC: DVI TeX filter for Printer Type $printerType not \c"                >/dev/console
  314.         echo "installed, print request aborted!!"                        >/dev/console
  315.         exit 2;
  316.     fi
  317.     ;;
  318.  
  319. .gf)
  320.     #
  321.     # They need a PLOT graphic filter, use
  322.     #
  323.     dependentFilter=$filterPathName/gf
  324.     if [ ! -x $dependentFilter ]
  325.     then
  326.         echo "NUC: PLOT filter for Printer Type $printerType not \c"                >/dev/console
  327.         echo "installed, print request aborted!!"                        >/dev/console
  328.         exit 2;
  329.     fi
  330.     ;;
  331.  
  332. .if)
  333.     #
  334.     # They need a interface filter only
  335.     #
  336.     dependentFilter=$filterPathName/if
  337.     if [ ! -x $dependentFilter ]
  338.     then
  339.         #
  340.         # Use "cat" as the default filter, with implied -c for
  341.         # control character stripping
  342.         #
  343.         dependentFilter=$DEFAULT_FILTER
  344.     fi
  345.     ;;
  346.  
  347. .nf)
  348.     #
  349.     # They need a DITROFF phototypesetter filter
  350.     #
  351.     dependentFilter=$filterPathName/nf
  352.     if [ ! -x $dependentFilter ]
  353.     then
  354.         echo "NUC: DITROFF filter for Printer Type $printerType not \c"                >/dev/console
  355.         echo "installed, print request aborted!!"                        >/dev/console
  356.         exit 2;
  357.     fi
  358.     ;;
  359.  
  360. .rf)
  361.     #
  362.     # They need a FORTRAN Text filter
  363.     #
  364.     dependentFilter=$filterPathName/rf
  365.     if [ ! -x $dependentFilter ]
  366.     then
  367.         echo "NUC: FORTRAN Text filter for Printer Type $printerType \c"            >/dev/console
  368.         echo "not installed, print request aborted!!"                        >/dev/console
  369.         exit 2;
  370.     fi
  371.     ;;
  372.  
  373. .tf)
  374.     #
  375.     # They need a TROFF phototypesetter filter
  376.     #
  377.     dependentFilter=$filterPathName/tf
  378.     if [ ! -x $dependentFilter ]
  379.     then
  380.         echo "NUC: TROFF filter for Printer Type $printerType \c"                >/dev/console
  381.         echo "not installed, print request aborted!!"                        >/dev/console
  382.         exit 2;
  383.     fi
  384.     ;;
  385.  
  386. .vf)
  387.     #
  388.     # They need a Raster Image filter
  389.     #
  390.     dependentFilter=$filterPathName/vf
  391.     if [ ! -x $dependentFilter ]
  392.     then
  393.         echo "NUC: TROFF filter for Printer Type $printerType \c"                >/dev/console
  394.         echo "not installed, print request aborted!!"                        >/dev/console
  395.         exit 2;
  396.     fi
  397.     ;;
  398.  
  399. *)
  400.     #
  401.     # How did we get called?
  402.     #
  403.     echo "$0: $ifProgramName Unknown print filter" >/dev/console;
  404.     exit 2;
  405.     ;;
  406. esac
  407.  
  408. #
  409. # Set up the PIPE to NetWare printer driver, and push the appropriate dependent
  410. # filter into the PIPE
  411. #
  412. NetWarePrinterDriver="$PRINTJOB_NUCPS -P $printerName $fileArgs \
  413.                         -n $userName $ChWidth $ChLength $BANNER"
  414.  
  415. if [ $dependentFilter = $DEFAULT_FILTER ]
  416. then
  417.     #
  418.     # Used to push cat(1), but just letting our driver pull from
  419.     # STDIN works just as well, with less overhead.
  420.     #
  421.     $PS_COMMENT_FILTER -P $printerName | $NetWarePrinterDriver
  422. else
  423.     "$dependentFilter" $argV | $PS_COMMENT_FILTER -P $printerName | $NetWarePrinterDriver
  424. fi
  425.  
  426. #
  427. # Return the status of the printjob_nucps child
  428. #
  429. exit $?;
  430.